break; /* no GPS */
}
- wpt->creation_time = basetime +
- ((data->hour & 0x1F) * 3600) + (data->min * 60) + data->sec;
+ wpt->SetCreationTime(basetime +
+ ((data->hour & 0x1F) * 3600) + (data->min * 60) + data->sec);
if (data->dsec) {
wpt->microseconds = (int)data->dsec * 10000;
}
break;
case XT_ISO_TIME:
case XT_ISO_TIME_MS:
- wpt->creation_time = xml_parse_time(s, &wpt->microseconds);
+ wpt->creation_time = xml_parse_time(s);
break;
case XT_NET_TIME: {
time_t tt = wpt->GetCreationTime();
#include "inifile.h"
#include "session.h"
+#include <QtCore/QDebug>
# include "src/core/datetime.h"
// Turn on Unicode in expat?
wp_flags wpt_flags;
QString icon_descr;
- gpsbabel::DateTime GetCreationTime() const { return creation_time; }
- void SetCreationTime(time_t t) { creation_time = t; }
+ gpsbabel::DateTime GetCreationTime() const {
+//QDateTime dt(creation_time);
+//qDebug() << dt.toString("dd.MM.yyyy hh:mm:ss.zzz");
+//fprintf(stderr, "ng %d\n", (int)creation_time);
+ return creation_time;
+}
+ void SetCreationTime(gpsbabel::DateTime t) { creation_time = t;
+//qDebug() << t.toString("dd.MM.yyyy hh:mm:ss.zzz");
+//fprintf(stderr, "ns %d\n", (int)t);
+}
+ void SetCreationTime(time_t t) { creation_time = t;
+//fprintf(stderr, "t %d\n", (int)t);
+}
void SetCreationTime(time_t t, int us) {
creation_time = t;
microseconds = us;
+//fprintf(stderr, "t/us %d %d\n", (int)t, us);
}
gpsbabel::DateTime creation_time;
int microseconds; /* Optional millionths of a second. */
#define str_iso8859_1_to_utf8(str) cet_str_iso8859_1_to_utf8((str))
/* this lives in gpx.c */
-gpsbabel::DateTime xml_parse_time(const char* cdatastr, int* microsecs);
+gpsbabel::DateTime xml_parse_time(const char* cdatastr);
xml_tag* xml_findfirst(xml_tag* root, const char* tagname);
xml_tag* xml_findnext(xml_tag* root, xml_tag* cur, const char* tagname);
}
logpart = xml_findfirst(curlog, "groundspeak:date");
if (logpart) {
- time_t logtime = xml_parse_time(logpart->cdata, NULL);
+ time_t logtime = xml_parse_time(logpart->cdata);
const struct tm* logtm = gmtime(&logtime);
gbfprintf(fd, "%d-%02d-%02d ", logtm->tm_year + 1900, logtm->tm_mon + 1, logtm->tm_mday);
}
void gl_trk_utc(const char* args, const char** unused)
{
- wpt_tmp->SetCreationTime(xml_parse_time(args, &wpt_tmp->microseconds));
+ wpt_tmp->SetCreationTime(xml_parse_time(args));
}
void gl_trk_lat(const char* args, const char** unused)
}
gpsbabel::DateTime
-xml_parse_time(const char* cdatastr, int* microsecs)
+xml_parse_time(const char* cdatastr)
{
int off_hr = 0;
int off_min = 0;
}
}
+ double fsec = 0;
pointstr = strchr(timestr, '.');
if (pointstr) {
+ sscanf(pointstr, "%le", &fsec);
+#if 0
+ /* Round to avoid FP jitter */
if (microsecs) {
- double fsec;
- sscanf(pointstr, "%le", &fsec);
- /* Round to avoid FP jitter */
*microsecs = .5 + (fsec * 1000000.0) ;
}
+#endif
*pointstr = '\0';
}
// 2038 but which we can't replace until Steven upgrades Qt.
// Baby steps.
QDateTime dt = QDateTime::fromTime_t(rv);
- if (microsecs) {
- dt = dt.addMSecs(*microsecs / 1000);
-// qDebug() << dt.toString("dd.MM.yyyy hh:mm:ss.zzz") << " ZZZ " << *microsecs;
+ if (fsec) {
+ dt = dt.addMSecs(fsec * 1000);
+// qDebug() << dt.toString("dd.MM.yyyy hh:mm:ss.zzz") << " ZZZ " << fsec;
}
return dt;
}
waypt_alloc_gc_data(wpt_tmp)->placer = xstrdup(cdatastrp);
break;
case tt_cache_log_date:
- gc_log_date = xml_parse_time(cdatastrp, NULL);
+ gc_log_date = xml_parse_time(cdatastrp);
break;
/*
* "Found it" logs follow the date according to the schema,
case tt_wpt_time:
case tt_trk_trkseg_trkpt_time:
case tt_rte_rtept_time:
- wpt_tmp->SetCreationTime(xml_parse_time(cdatastrp, &wpt_tmp->microseconds));
+ wpt_tmp->SetCreationTime(xml_parse_time(cdatastrp));
break;
case tt_wpt_cmt:
case tt_rte_rtept_cmt:
wpt->latitude = fread_double(file_in);
wpt->longitude = fread_double(file_in);
convert_datum(&wpt->latitude, &wpt->longitude);
- wpt->creation_time = fread_long(file_in);
+ wpt->SetCreationTime(fread_long(file_in));
if (wpt->creation_time) {
wpt->creation_time += EPOCH89DIFF;
}
void
gtc_trk_utc(const char* args, const char** unused)
{
- wpt_tmp->creation_time = xml_parse_time(args, NULL);
+ wpt_tmp->creation_time = xml_parse_time(args);
}
void
logpart = xml_findfirst(curlog, "groundspeak:date");
if (logpart) {
- logtime = xml_parse_time(logpart->cdata, NULL);
+ logtime = xml_parse_time(logpart->cdata);
logtm = localtime(&logtime);
if (logtm) {
gbfprintf(file_out,
nmea_set_waypoint_time(waypoint* wpt, struct tm* time, int microseconds)
{
if (time->tm_year == 0) {
- wpt->creation_time = ((((time_t)time->tm_hour * 60) + time->tm_min) * 60) + time->tm_sec;
- wpt->microseconds = microseconds;
+ wpt->SetCreationTime(((((time_t)time->tm_hour * 60) + time->tm_min) * 60) + time->tm_sec, microseconds);
if (wpt->wpt_flags.fmt_use == 0) {
wpt->wpt_flags.fmt_use = 1;
}
} else {
- wpt->creation_time = mkgmtime(time);
- wpt->microseconds = microseconds;
+ wpt->SetCreationTime(mkgmtime(time), microseconds);
if (wpt->wpt_flags.fmt_use != 0) {
wpt->wpt_flags.fmt_use = 0;
}
void wpt_time(const char* args, const char** unused)
{
- wpt_tmp->creation_time = xml_parse_time(args, &wpt_tmp->microseconds);
+ wpt_tmp->creation_time = xml_parse_time(args);
}
void wpt_coord(const char* args, const char** attrv)
logpart = xml_findfirst(curlog, "groundspeak:date");
if (logpart) {
- logtime = xml_parse_time(logpart->cdata, NULL);
+ logtime = xml_parse_time(logpart->cdata);
struct tm* logtm = localtime(&logtime);
if (logtm) {
char* temp;
// with, as a practical matter, we have no date, so don't even compute
// or set it.
if (create_date > 2440587) {
- wpt_tmp->creation_time = lowranceusr4_get_timestamp(create_date,
- create_time);
+ wpt_tmp->SetCreationTime(lowranceusr4_get_timestamp(create_date,
+ create_time));
}
/* Unused byte */
gbfputflt(WAYPT_GET(wpt, proximity, 0.0), file_out);
/* Creation date/time */
- gbfputint32(lowranceusr4_jd_from_timestamp(wpt->creation_time), file_out);
- gbfputint32(wpt->creation_time, file_out);
+ gbfputint32(lowranceusr4_jd_from_timestamp(wpt->GetCreationTime()), file_out);
+ gbfputint32(wpt->GetCreationTime(), file_out);
/* Unused byte */
gbfputc(0, file_out);
gbfputc(0, file_out);
/* Timestamp */
- gbfputint32(wpt->creation_time, file_out);
+ gbfputint32(wpt->GetCreationTime(), file_out);
/* Long/Lat */
gbfputdbl(wpt->longitude * DEGREESTORADIANS, file_out);
tm.tm_mon = be_read16(&rec->crt_mon) - 1;
tm.tm_year = be_read16(&rec->crt_year) - 1900;
if (mkgmtime(&tm) > 0) {
- wpt_tmp->creation_time = mktime(&tm);
+ wpt_tmp->SetCreationTime(mktime(&tm));
}
waypt_add(wpt_tmp);
if (wpt_tmp->altitude < unknown_alt + 1) {
wpt_tmp->altitude = unknown_alt;
}
- wpt_tmp->creation_time = gbfgetint32(mapsend_file_in);
+ time_t t = gbfgetint32(mapsend_file_in);
valid = gbfgetint32(mapsend_file_in);
/* centiseconds only in >= version 3.0 */
} else {
centisecs = 0;
}
- wpt_tmp->microseconds = CENTI_TO_MICRO(centisecs);
+ wpt_tmp->SetCreationTime(t, CENTI_TO_MICRO(centisecs));
track_add_wpt(track_head, wpt_tmp);
}
nmea_set_waypoint_time(waypoint* wpt, struct tm* time, int microseconds)
{
if (time->tm_year == 0) {
- wpt->creation_time = ((((time_t)time->tm_hour * 60) + time->tm_min) * 60) + time->tm_sec;
- wpt->microseconds = microseconds;
+ wpt->SetCreationTime(((((time_t)time->tm_hour * 60) + time->tm_min) * 60) + time->tm_sec, microseconds);
if (wpt->wpt_flags.fmt_use == 0) {
wpt->wpt_flags.fmt_use = 1;
without_date++;
}
} else {
- wpt->creation_time = mkgmtime(time);
- wpt->microseconds = microseconds;
+ wpt->SetCreationTime(mkgmtime(time), microseconds);
if (wpt->wpt_flags.fmt_use != 0) {
wpt->wpt_flags.fmt_use = 0;
without_date--;
} else if (strcmp(avp[0], "lon") == 0) {
wpt->longitude = atof(avp[1]);
} else if (strcmp(avp[0], "timestamp") == 0) {
- wpt->creation_time = xml_parse_time(avp[1], &wpt->microseconds);
+ wpt->creation_time = xml_parse_time(avp[1]);
}
avp += 2;
logpart = xml_findfirst(curlog, "groundspeak:date");
if (logpart) {
- logtime = xml_parse_time(logpart->cdata, NULL);
+ logtime = xml_parse_time(logpart->cdata);
logtm = localtime(&logtime);
if (logtm) {
docprintf(15,
if (ppdb_decode_tm(str, &tm)) {
tm.tm_year -= 1900;
tm.tm_mon--;
- wpt_tmp->creation_time = mkgmtime(&tm);
+ wpt_tmp->SetCreationTime(mkgmtime(&tm));
}
break;
case 5: /* name */
logpart = xml_findfirst(curlog, "groundspeak:date");
if (logpart) {
- logtime = xml_parse_time(logpart->cdata, NULL);
+ logtime = xml_parse_time(logpart->cdata);
logtm = localtime(&logtime);
if (logtm) {
gbfprintf(file_out,
case fld_iso_time:
is_localtime = 2; /* fix result */
- wpt->creation_time = xml_parse_time(s, &wpt->microseconds);
+ wpt->SetCreationTime(xml_parse_time(s));
break;
case fld_time:
struct tm tm;
tm = *gmtime(&t);
if (opt_utc) {
- wpt->creation_time = mkgmtime(&tm);
+ wpt->SetCreationTime(mkgmtime(&tm));
} else {
- wpt->creation_time = mklocaltime(&tm);
+ wpt->SetCreationTime(mklocaltime(&tm));
}
} else {
- wpt->creation_time = t;
+ wpt->SetCreationTime(t);
}
} else if (time >= 0) {
- wpt->creation_time = time;
+ wpt->SetCreationTime(time);
} else if (date >= 0) {
- wpt->creation_time = date;
+ wpt->SetCreationTime(date);
} else if (ymd.tm_year || ymd.tm_mon || ymd.tm_mday) {
if (ymd.tm_year < 100) {
if (ymd.tm_year <= 70) {
#include <stdio.h>
#include <math.h>
+#include <QtCore/QDebug>
#include "defs.h"
#include "cet_util.h"
return NULL;
}
- QDateTime dt = QDateTime::fromTime_t(creation_time);
+ QDateTime dt = GetCreationTime();
dt = dt.addMSecs(MICRO_TO_MILLI(microseconds));
dt = dt.toUTC();
+// qDebug() << dt.toString("dd.MM.yyyy hh:mm:ss.zzz") << " CML " << microseconds;
const char* format = "yyyy-MM-ddTHH:mm:ssZ";
if (dt.time().msec()) {
void wfff_first(const char *args, const char **unused)
{
if (args) {
- ap_first = xml_parse_time(args, NULL);
+ ap_first = xml_parse_time(args);
}
}
}
} else if (strcmp(avp[0], "timestamp") == 0) {
if (wpt) {
- wpt->creation_time = xml_parse_time(avp[1], &wpt->microseconds);
+ wpt->creation_time = xml_parse_time(avp[1]);
}
} else if (strcmp(avp[0], "icon") == 0) {
if (wpt) {